﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BestCode.Creds.Data;
using BestCode.Creds.Entities;

namespace BestCode.Creds.Business
{
    public class FieldDefinitionBusiness : BusinessBase<FieldDefinition>
    {
        private IFieldDefinitionDao dao = DataFactory.Current.GetFieldDefinitionDao();

        public FieldDefinitionBusiness()
        {
            setDao(dao);
        }

        public override ObservableCollection<FieldDefinition> SearchByFilter(string parameter)
        {
            return new ObservableCollection<FieldDefinition>(dao.GetByFilter(parameter));
        }

        public ObservableCollection<FieldDefinition> GetByEntityId(int entityId)
        {
            return new ObservableCollection<FieldDefinition>(dao.GetByEntityId(entityId));
        }

        public ObservableCollection<FieldDefinition> GetEnabledsByEntity(int entityId)
        {
            return new ObservableCollection<FieldDefinition>(dao.GetByEntityId(entityId).Where(p => p.IsEnabled));
        }

    }
}
